﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace personalplaner.common.converters
{
	public class StringToBoolConverter : IValueConverter
	{

		/// <summary>
		/// Returns true, if value is equal to parameter.
		/// </summary>
		/// <param name="value"></param>
		/// <param name="targetType"></param>
		/// <param name="parameter"></param>
		/// <param name="culture"></param>
		/// <returns></returns>
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value != null && value as string == parameter as string)
				return true;

			return false;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if ((bool)value)
				return parameter;

			return null;
		}
	}
}
